# Copyright 2018- The Pixie Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

load("//bazel:pl_build_system.bzl", "pl_cc_binary", "pl_cc_library_internal", "pl_cc_test")

package(default_visibility = [
    "//experimental:__subpackages__",
    "//src:__subpackages__",
])

pl_cc_library_internal(
    name = "cc_library",
    srcs = glob(
        ["*.cc"],
        exclude = [
            "**/*_test.cc",
            "**/*_benchmark.cc",
        ],
    ),
    hdrs = glob(
        ["*.h"],
        exclude = ["test_utils.h"],
    ),
    deps = [
        "//src/common/base/statuspb:status_pl_cc_proto",
        "@com_google_farmhash//:farmhash",
        "@com_google_googletest//:gtest_prod",
    ],
)

pl_cc_test(
    name = "env_test",
    srcs = ["env_test.cc"],
    deps = [":cc_library"],
)

pl_cc_test(
    name = "status_test",
    srcs = ["status_test.cc"],
    deps = [
        ":cc_library",
        "//src/common/base/testproto:test_pl_cc_proto",
    ],
)

pl_cc_test(
    name = "statusor_test",
    srcs = ["statusor_test.cc"],
    deps = [":cc_library"],
)

pl_cc_test(
    name = "error_test",
    srcs = ["error_test.cc"],
    deps = [":cc_library"],
)

pl_cc_test(
    name = "logging_test",
    srcs = ["logging_test.cc"],
    tags = ["no_asan"],
    deps = [":cc_library"],
)

pl_cc_test(
    name = "defer_test",
    srcs = ["defer_test.cc"],
    deps = [":cc_library"],
)

pl_cc_test(
    name = "time_test",
    srcs = ["time_test.cc"],
    deps = [":cc_library"],
)

pl_cc_test(
    name = "file_test",
    srcs = ["file_test.cc"],
    deps = [":cc_library"],
)

pl_cc_test(
    name = "types_test",
    srcs = ["types_test.cc"],
    deps = [":cc_library"],
)

pl_cc_test(
    name = "byte_utils_test",
    srcs = ["byte_utils_test.cc"],
    deps = [":cc_library"],
)

pl_cc_test(
    name = "utils_test",
    srcs = ["utils_test.cc"],
    deps = [":cc_library"],
)

pl_cc_test(
    name = "inet_utils_test",
    srcs = ["inet_utils_test.cc"],
    deps = [":cc_library"],
)

pl_cc_test(
    name = "magic_enum_test",
    srcs = ["magic_enum_test.cc"],
    deps = [
        ":cc_library",
        "//src/common/base/testproto:test_pl_cc_proto",
    ],
)

pl_cc_test(
    name = "enum_utils_test",
    srcs = ["enum_utils_test.cc"],
    deps = [":cc_library"],
)

pl_cc_binary(
    name = "bytes_to_int_benchmark",
    srcs = ["bytes_to_int_benchmark.cc"],
    deps = [
        "@com_google_benchmark//:benchmark_main",
    ],
)
